<?php
if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])){
	header($_SERVER['HTTP_HOST']);
	exit();
} 
?>
<div id="px_message"></div>

<form action="<?php echo $this->pluginUrl;?>galleryBuildAction" method="post">
<div class="wrap">
	<a name="error" id="error"></a>
	<div id="loaderAnimation"></div>
	<h2><?php _e('PhotoXhibit Build Gallery', 'photoxhibit'); ?></h2>
	<input type="hidden" id="px_gidHidden" name="px_gidHidden" value="<?php echo $px_model->cur_gallery_id;?>"/>
	<input type="hidden" id="px_pluginid" name="px_pluginid" value="<?php echo $px_model->cur_gallery_info->plugin_id;?>"/>
	<input type="hidden" name="px_serviceHidden" value=""/>
	<input type="hidden" name="px_goBackToHidden" value=""/>
	<input type="hidden" name="px_currentScreen" value="px_services"/>
    
    <input id="curplugin_id" type="hidden" name="curplugin_id" value=""/>
    <input id="gallery_extra" type="hidden" name="gallery_extra" value=""/>
    <input id="gallery_id" type="hidden" name="gallery_id" value=""/>
    <input id="gallery_params" type="hidden" name="gallery_params" value=""/>
    <input id="gallery_structure" type="hidden" name="gallery_structure" value=""/>
    <input id="gallery_title" type="hidden" name="gallery_title" value=""/>
    <input id="gallery_uselarge" type="hidden" name="gallery_uselarge" value=""/>
    <input id="images" type="hidden" name="images" value=""/>
    <input id="plugin_id" type="hidden" name="plugin_id" value=""/>

    <?php if( $px_model->cur_gallery_info ):?>
	
    <div class="wrap">
    	<fieldset class="options">
        	<legend>Current Gallery</legend>
            
            <table cellpadding="3" cellspacing="0" border="0" style="padding-bottom:2em;">
            	<tr>
                    <td>
                    	<a href="admin.php?page=px_manage&amp;action=edit_styles&amp;pxgid=<?php echo $px_model->cur_gallery_id;?>"
                        	><?php _e('Edit Styles', 'photoxhibit'); ?></a></td>
                    <td><a href="admin.php?page=px_manage&amp;action=edit_attrs&amp;pxgid=<?php echo $px_model->cur_gallery_id;?>"
                    		><?php _e('Edit Image Data', 'photoxhibit'); ?></a></td>
                    <td><a href="admin.php?page=px_manage&amp;action=delete_gallery&amp;pxgid=<?php echo $px_model->cur_gallery_id;?>" class="px_optDelete"
                    		><?php _e('Delete', 'photoxhibit'); ?></a></td>
				</tr>
			</table>
            <?php $this->get_css( true );?>
            <?php $this->get_js( true );?>
            <?php $this->build_img_structure();?>
            
    	<pre>
<?php #print_r($this);?>
<?php #print_r($px_model);?>
<?php #print_r($px_model->cur_image_group);?>
<?php #print_r( $px_controller->vars['plugin_cache'] );?>
        </pre>
        </fieldset>
    </div>
    
    <?php endif; ?>
    
	<div id="px_holder">
		<div id="px_gut">
			<div id="px_services" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildServices.php');?>
			</div>

			<?php if($px_controller->vars['use_picasa']==1):?>
			
			<div id="px_picasaOptions" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildPicasaOptions.php');?>
			</div>
			<div id="px_picasaBasic" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildPicasaBasic.php');?>
			</div>
			<div id="px_picasaAdvance" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildPicasaAdvanced.php');?>
			</div>
			<div id="px_picasaThumbnails" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildPicasaThumbnails.php');?>
			</div>
			
			<?php endif;?>

			<?php if($px_controller->vars['use_flickr']==1):?>

			<div id="px_buildFlickrOptions" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildFlickrOptions.php');?>
			</div>
			<div id="px_buildFlickrBasic" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildFlickrBasic.php');?>
			</div>
			<div id="px_buildFlickrPhotoset" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildFlickrPhotoset.php');?>
			</div>
			<div id="px_buildFlickrSearch" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildFlickrSearch.php');?>
			</div>
			<div id="px_buildFlickrAPI" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildFlickrAPI.php');?>
			</div>
			<div id="px_buildFlickrThumbnails" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildFlickrThumbnails.php');?>
			</div>

			<?php endif;?>

			<?php if($px_controller->vars['use_smugmug']==1):?>

			<div id="px_buildSmugMugAdvance" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildSmugMugAdvance.php');?>
			</div>
			<div id="px_buildSmugMugThumbnails" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildSmugMugThumbnails.php');?>
			</div>
			
			<?php endif;?>
	
			<?php if($px_controller->vars['use_album']==1):?>
			
			<div id="px_buildAlbumList" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildAlbumList.php');?>
			</div>
			<div id="px_buildAlbumThumbnails" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildAlbumThumbnails.php');?>
			</div>

			<?php endif;?>


			<?php if($px_controller->vars['use_local']==1):?>
			
			<div id="px_buildLocal" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildLocal.php');?>
			</div>
			
			<?php endif;?>
			
			<?php if($px_controller->vars['use_browse']==1):?>
			
			<div id="px_buildBrowse" class="px_child">
				<?php $this->loadView('px_admin_gallery_builder/buildBrowse.php');?>
			</div>
			
			<?php endif;?>

		</div>
	</div>

		<table id="px_table" width="100%" cellspacing="15" style="width:909px;margin:0 auto;padding:0;">
			<thead>
				<tr>
					<th><?php _e('Doubleclick on the images you want to add and they will be moved to the box on the right.', 'photoxhibit'); ?></th>
					<th><?php _e('Below, if you have not figured it out, is the box on the right.  Doubleclick on a image if you want to remove it.  Click and drag an image if you want to reorder it.', 'photoxhibit'); ?></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td width="50%" valign="top" align="center">
						<a href="#" id="px_add_all"><?php _e('Add All', 'photoxhibit'); ?></a> | <a href="#" id="px_add_all_selected"><?php _e('Add Selected', 'photoxhibit'); ?></a><br/>
						<?php _e('note: if you have a lot of images the browser may hang for a second or so', 'photoxhibit'); ?>
					</td>
					<td width="50%" valign="top" align="center">
						<a href="#" id="px_remove_all"><?php _e('Remove All', 'photoxhibit'); ?></a>
                        |
                        <a href="#" id="px_remove_all_selected"><?php _e('Remove Selected', 'photoxhibit'); ?></a><br/>
						<?php _e('note: if you have a lot of images the browser may hang for a second or so', 'photoxhibit'); ?>
					</td>
				</tr>
				<tr>
					<td width="50%" style="border:1px solid #ccc;padding:0;" valign="top">
						<ul id="selectList"></ul>
					</td>
					<td width="50%" style="border:1px solid #ccc;padding:0;" valign="top">
						<ul id="imageList"><?php $this->build_img_admin_list();?></ul>
					</td>
				</tr>
			</tbody>
		</table>
</div>
<?php $this->loadView('px_admin_gallery_builder/buildStructure.php');?>
<?php $this->loadView('px_admin_gallery_builder/buildGalleryOptions.php');?>
</form>